import React, { Component } from 'react'
import { context } from '../context'
// 哪个组件要接收数据,就使用context.Consumer
export default class Son extends Component {
  // 给当前组件添加静态属性 contextType, 值为context对象
  static contextType = context
  render() {
    console.log(this.context)
    return (
      <div>
        <h1>Son</h1>
        <p>{this.context}</p>
      </div>
    )
  }
}
